using System.Collections.Generic;
using NodeCanvas.Variables;
using UnityEngine;

namespace NodeCanvas.Actions
{
	[Category("GameObject")]
	[Description("Note that this is very slow")]
	public class FindObjectsOfType : ActionTask
	{
		public BBString type = new BBString
		{
			value = "Camera"
		};

		[BlackboardOnly]
		public BBGameObjectList saveAs;

		protected override void OnExecute()
		{
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			List<GameObject> list = new List<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject gameObject in array2)
			{
				if (gameObject.GetComponent(type.value) != null)
				{
					list.Add(gameObject);
				}
			}
			saveAs.value = list;
			EndAction(list.Count > 0);
		}
	}
}
